const User = require('../models/User')
const md5 = require('md5')

//用户注册
const register = async (req, res) => {
  // 接受前端传过来的数据，然后往数据里面添加用户
  req.body.username = '张三'
  req.body.age = 18
  req.body.phone = '12345678901'
  req.body.email = 'qweqw@qq.com'
  req.body.pwd = md5('123456')
  let result = await User.addUser(req.body)
  if (result.affectedRows == 1) {
    res.json({ code: 200, msg: '注册成功', userId: result.insertId })
  } else {
    res.json({ code: -1, msg: '注册失败' })
  }
}
//用户登录
const login = async (req, res) => {
  //用户登录 jwt
}
module.exports = {
  register,
}
